package com.ruoyi.xp.order.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.xp.order.domain.OrderItemGoods;
import com.ruoyi.xp.order.service.IOrderItemGoodsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 虾皮订单明细仓库货物信息Controller
 * 
 * @author chdx
 * @date 2023-01-22
 */
@Controller
@RequestMapping("/order/OrderItemGoods")
public class OrderItemGoodsController extends BaseController
{
    private String prefix = "order/OrderItemGoods";

    @Autowired
    private IOrderItemGoodsService orderItemGoodsService;

    @RequiresPermissions("order:OrderItemGoods:view")
    @GetMapping()
    public String OrderItemGoods()
    {
        return prefix + "/OrderItemGoods";
    }

    /**
     * 查询虾皮订单明细仓库货物信息列表
     */
    @RequiresPermissions("order:OrderItemGoods:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(OrderItemGoods orderItemGoods)
    {
        startPage();
        List<OrderItemGoods> list = orderItemGoodsService.selectOrderItemGoodsList(orderItemGoods);
        return getDataTable(list);
    }

    /**
     * 导出虾皮订单明细仓库货物信息列表
     */
    @RequiresPermissions("order:OrderItemGoods:export")
    @Log(title = "虾皮订单明细仓库货物信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(OrderItemGoods orderItemGoods)
    {
        List<OrderItemGoods> list = orderItemGoodsService.selectOrderItemGoodsList(orderItemGoods);
        ExcelUtil<OrderItemGoods> util = new ExcelUtil<OrderItemGoods>(OrderItemGoods.class);
        return util.exportExcel(list, "虾皮订单明细仓库货物信息数据");
    }

    /**
     * 新增虾皮订单明细仓库货物信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存虾皮订单明细仓库货物信息
     */
    @RequiresPermissions("order:OrderItemGoods:add")
    @Log(title = "虾皮订单明细仓库货物信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(OrderItemGoods orderItemGoods)
    {
        return toAjax(orderItemGoodsService.insertOrderItemGoods(orderItemGoods));
    }

    /**
     * 修改虾皮订单明细仓库货物信息
     */
    @RequiresPermissions("order:OrderItemGoods:edit")
    @GetMapping("/edit/{orderItemGoodsId}")
    public String edit(@PathVariable("orderItemGoodsId") Long orderItemGoodsId, ModelMap mmap)
    {
        OrderItemGoods orderItemGoods = orderItemGoodsService.selectOrderItemGoodsByOrderItemGoodsId(orderItemGoodsId);
        mmap.put("orderItemGoods", orderItemGoods);
        return prefix + "/edit";
    }

    /**
     * 修改保存虾皮订单明细仓库货物信息
     */
    @RequiresPermissions("order:OrderItemGoods:edit")
    @Log(title = "虾皮订单明细仓库货物信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(OrderItemGoods orderItemGoods)
    {
        return toAjax(orderItemGoodsService.updateOrderItemGoods(orderItemGoods));
    }

    /**
     * 删除虾皮订单明细仓库货物信息
     */
    @RequiresPermissions("order:OrderItemGoods:remove")
    @Log(title = "虾皮订单明细仓库货物信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(orderItemGoodsService.deleteOrderItemGoodsByOrderItemGoodsIds(ids));
    }
}
